package notes.java.java8.demo.streams;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/** 扁平化*/
public class S5_Flatmap {

	public static void main(String[] args) {
		
		// 测试数据
		List<String> list = new ArrayList<String>(Arrays.asList("Hello", "World"));
		
		// 扁平化(拆分成一个个字母)
		List<String> ls = list.stream().flatMap(s->Arrays.stream(s.split(""))).collect(Collectors.toList());
	
		// 输出
		ls.forEach(s-> {
			System.out.print(s + " ");
		});
	}
}
